package com.example.cdmuseum.ui.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.example.cdmuseum.R;
import com.example.cdmuseum.bean.BoutiqueLv;
import com.example.cdmuseum.base.LazyFragment;
import com.example.cdmuseum.ui.activity.BoutiqueHomeActivity;
import com.example.cdmuseum.ui.activity.BoutiqueHomeActivity1;
import com.example.cdmuseum.ui.activity.BoutiqueHomeActivity2;
import com.example.cdmuseum.ui.activity.BoutiqueHomeActivity3;
import com.example.cdmuseum.ui.activity.BoutiqueHomeActivity4;
import com.example.cdmuseum.ui.adapter.BoutiqueFragmentAdapter;

import java.util.LinkedList;
import java.util.List;

import butterknife.BindView;


public class BoutiqueFragment extends LazyFragment {

    private List<BoutiqueLv> mData = null;
    //    private Context mContext;
    private BoutiqueFragmentAdapter mAdapter = null;
    //
    @BindView(R.id.lv_data)
    ListView list_animal;


    @Override
    protected int getLayoutId() {
        return R.layout.fragment_store;
    }

    @Override
    protected void loadData() {
        initData();


    }

    public void initData() {
        mData = new LinkedList<BoutiqueLv>();
        mData.add(new BoutiqueLv("陶瓷类展示", "陶瓷类展示", R.drawable.boutique_1));
        mData.add(new BoutiqueLv("书画类展示", "书画类展示", R.drawable.boutique_2));
        mData.add(new BoutiqueLv("玉石器展示", "玉石器展示", R.drawable.boutique_3));
        mData.add(new BoutiqueLv("珍藏展示", "珍藏展示", R.drawable.boutique_4));
//        mData.add(new BoutiqueLv("杂项类展示", "杂项类展示", R.drawable.boutique_5));
        mAdapter = new BoutiqueFragmentAdapter((LinkedList<BoutiqueLv>) mData, getContext());
        list_animal.setAdapter(mAdapter);
        list_animal.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(getContext(), "点击" + i, Toast.LENGTH_SHORT).show();
                if (i==0){
                    Intent intent = new Intent(getContext(), BoutiqueHomeActivity.class);
                    intent.putExtra("index", mData.get(i).getaIcon());
                    intent.putExtra("title", mData.get(i).getaName());
                    startActivity(intent);
                }
                else if (i==1){
                    Intent intent = new Intent(getContext(), BoutiqueHomeActivity1.class);
                    intent.putExtra("index", mData.get(i).getaIcon());
                    intent.putExtra("title", mData.get(i).getaName());
                    startActivity(intent);
                }

                else if (i==2){
                    Intent intent = new Intent(getContext(), BoutiqueHomeActivity2.class);
                    intent.putExtra("index", mData.get(i).getaIcon());
                    intent.putExtra("title", mData.get(i).getaName());
                    startActivity(intent);
                }
                else if (i==3){
                    Intent intent = new Intent(getContext(), BoutiqueHomeActivity3.class);
                    intent.putExtra("index", mData.get(i).getaIcon());
                    intent.putExtra("title", mData.get(i).getaName());
                    startActivity(intent);
                }
                else {
                    Intent intent = new Intent(getContext(), BoutiqueHomeActivity4.class);
                    intent.putExtra("index", mData.get(i).getaIcon());
                    intent.putExtra("title", mData.get(i).getaName());
                    startActivity(intent);
                }

//                Intent intent = new Intent(getContext(), BoutiqueHomeActivity.class);
//                intent.putExtra("index", mData.get(i).getaIcon());
//                intent.putExtra("title", mData.get(i).getaName());
//                startActivity(intent);




            }



        });
    }


}